package com.ygqh.baby.model;

import com.ygqh.baby.ao.ReturnReasonType;
import com.ygqh.baby.ao.ReturnType;
import com.ygqh.baby.ao.SalesPlatform;
import com.ygqh.baby.constant.Constant;

import java.math.BigDecimal;

/**
 * @Author: sunshuo
 * @Date: 2019/5/6 14:11
 * @Version: 1.0
 */
public class ReturnOrderReportModel {

	private String platformNo;

	private ReturnType returnType;

	private ReturnReasonType returnReasonType;

	private Long returnItemQuantity;

	private Long itemQuantity = 0L;

	private Long productId;

	private String productName;

	private Long returnOrderCount;

	private Long orderCount;

	public String getPlatformNo() {
		return platformNo;
	}

	public void setPlatformNo(String platformNo) {
		this.platformNo = platformNo;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public ReturnType getReturnType() {
		return returnType;
	}

	public void setReturnType(ReturnType returnType) {
		this.returnType = returnType;
	}

	public ReturnReasonType getReturnReasonType() {
		return returnReasonType;
	}

	public void setReturnReasonType(ReturnReasonType returnReasonType) {
		this.returnReasonType = returnReasonType;
	}

	public Long getReturnItemQuantity() {
		return returnItemQuantity;
	}

	public void setReturnItemQuantity(Long returnItemQuantity) {
		this.returnItemQuantity = returnItemQuantity;
	}

	public BigDecimal getReturnItemRate() {
		if (itemQuantity == null || returnItemQuantity == null) {
			return null;
		}
		if (itemQuantity == 0) {
			return BigDecimal.ZERO;
		}
		return BigDecimal.valueOf(returnItemQuantity)
				.divide(BigDecimal.valueOf(itemQuantity), 2, BigDecimal.ROUND_HALF_UP);
	}

	public BigDecimal getReturnCountRate() {
		if (orderCount == null || returnOrderCount == null) {
			return null;
		}
		if (orderCount == 0) {
			return BigDecimal.ZERO;
		}
		return BigDecimal.valueOf(returnOrderCount)
				.divide(BigDecimal.valueOf(orderCount), 2, BigDecimal.ROUND_HALF_UP);
	}

	public Long getItemQuantity() {
		return itemQuantity;
	}

	public void setItemQuantity(Long itemQuantity) {
		this.itemQuantity = itemQuantity;
	}

	public Long getProductId() {
		return productId;
	}

	public void setProductId(Long productId) {
		this.productId = productId;
	}

	public Long getReturnOrderCount() {
		return returnOrderCount;
	}

	public void setReturnOrderCount(Long returnOrderCount) {
		this.returnOrderCount = returnOrderCount;
	}

	public Long getOrderCount() {
		return orderCount;
	}

	public void setOrderCount(Long orderCount) {
		this.orderCount = orderCount;
	}

	public SalesPlatform getSalesPlatform() {
		if (Constant.YIIGOO_PLATFORM_NO.equals(platformNo)) {
			return SalesPlatform.Yiigoo;
		}
		if (Constant.YIJIADIAN_PLATFORM_NO.equals(platformNo)) {
			return SalesPlatform.Yijiadian;
		}
		return null;
	}

	public String getSalesPlatformDesc() {
		SalesPlatform salesPlatform = getSalesPlatform();
		return salesPlatform == null ? null : salesPlatform.getTitle();
	}

	public String getReturnTypeDesc() {
		return returnType == null ? null : returnType.getTitle();
	}

	public String getReturnReasonTypeDesc() {
		return returnReasonType == null ? null : returnReasonType.getTitle();
	}
}
